#297mm×420mm
import os
from PIL import Image  
  
# 打开图像  
  
# 获取原始尺寸  


for file in os.listdir(path='/home/unionsys/Pictures/rentou/'):
	print('/home/unionsys/Pictures/rentou/'+file)
	img = Image.open('/home/unionsys/Pictures/rentou/'+file)
	# 打印照片的长和宽  
	width, height = img.size  
	#print("照片的尺寸：{} x {}".format(width, height))
	img_w=width/0.8080808080808081
	img_h=img_w/297*420
	new_img = Image.new('RGB', (int(img_w), int(img_h)), color = 'white')  
	h=int((img_h-height)/2)
	w=int((img_w-width)/2)
	new_img.paste(img, (w,h))
	new_img.save('/home/unionsys/Pictures/rentou/'+file)


